package packml;

import java.rmi.RemoteException;


public class CheckOrderComplete extends Packmlhandler implements Runnable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private boolean orderState;

	public CheckOrderComplete(){}

	public void run(){
		while(true){
			delay(2000);
			orderIsCompleted();
		}
			
			
	}
	public synchronized void delay(int i) {
		try {
			wait(i);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}
	
	public void orderIsCompleted() {
		
		try {
			orderState = packmlhandlerWorkCellController.isCurrentOrderCompleted();
//			System.out.println("check order state "+orderState);
//			System.out.println(" order "+order);
		} catch (RemoteException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		if(orderState){
			order="Complete";
		}
		else
			order=null;
		
	}

}
